package com.repair.system.controller;

import com.repair.system.service.FaultRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
@RequiredArgsConstructor
public class HomeController {
    private final FaultRecordService faultRecordService;
    
    @GetMapping("/")
    public String home(Model model) {
        model.addAttribute("totalFaults", faultRecordService.getAllFaults().size());
        model.addAttribute("pendingFaults", faultRecordService.getPendingFaultCount());
        model.addAttribute("resolvedFaults", faultRecordService.getResolvedFaultCount());
        model.addAttribute("recentFaults", faultRecordService.getRecentFaults());
        return "index";
    }
}
